//package ajax;
//
//import javax.servlet.*;
//import javax.servlet.annotation.WebFilter;
//import javax.servlet.annotation.WebInitParam;
//import java.io.IOException;
//
///**
// * @Author wuchao66
// * @Date 2023/6/5 10:14
// * @PackageName:${PACKAGE_NAME}
// * @ClassName: ${NAME}
// * @Description: TODO
// * @Param
// * @Version 1.0
// */
//@WebFilter(filterName = "Filter123",urlPatterns = "/*",
//        initParams ={@WebInitParam(name = "encode",value = "utf-8")})
////拔插技术
//public class Filter123 implements Filter {//过滤utf-8
//    private  String encode;//定义一个今天要用的编码规则
//    public void destroy() {//摧毁
//        if(this.encode!=null){
//            this.encode=null;
//        }
//    }
//    public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws ServletException, IOException {
//        String encode= req.getCharacterEncoding();//拿到整个过来的请求自带的编码规则
//        if(encode==null||encode==""||!encode.equals(this.encode)){
//            req.setCharacterEncoding(this.encode);
//        }
//        chain.doFilter(req, resp);//链式操作
//    }
//    public void init(FilterConfig config) throws ServletException {
//        //初始化--今天需要的编码规则
//      String encode= config.getInitParameter("encode");
//      this.encode=encode;//拿到值复制给今天的规则
//
//    }
//
//}
